import time

from selenium import webdriver
from selenium.webdriver.common.by import By

from unittest import TestCase
class TestLogin(TestCase):
    def testLogin1(self):
        driver = webdriver.Chrome()

        driver.get("http://localhost:90/")

        driver.maximize_window()

        driver.find_element(By.XPATH, "/html/body/div/div/div/div[2]/a").click()

        time.sleep(2)
        username = "wangwu"
        password = "123456"
        repassword = "123456"

        driver.find_element(By.XPATH,"//input[@id='username' and @name='username']").send_keys(username)
        time.sleep(2)
        driver.find_element(By.XPATH, "//input[@id='password' and @name='password']").send_keys(password)
        time.sleep(2)
        driver.find_element(By.XPATH, "//input[@id='repassword' and @name='repassword']").send_keys(repassword)
        time.sleep(2)
        a = driver.find_element(By.XPATH, "//input[@id='password' and @name='password']").text
        b = driver.find_element(By.XPATH, "//input[@id='repassword' and @name='repassword']").text
        self.assertEqual(a, b)

        time.sleep(2)
        driver.find_element(By.XPATH, "//*[@id='login_btn']").click()
        time.sleep(2)




        driver.quit()





    def testLogin2(self):
        driver = webdriver.Chrome()

        driver.get("http://localhost:90/")

        driver.maximize_window()

        driver.find_element(By.XPATH, "/html/body/div/div/div/div[2]/a").click()

        time.sleep(2)
        username = "wangwu1"
        password = "123456"
        repassword = "123456"

        driver.find_element(By.XPATH, "//input[@id='username' and @name='username']").send_keys(username)
        time.sleep(2)
        driver.find_element(By.XPATH, "//input[@id='password' and @name='password']").send_keys(password)
        time.sleep(2)
        driver.find_element(By.XPATH, "//input[@id='repassword' and @name='repassword']").send_keys(repassword)
        time.sleep(2)
        a = driver.find_element(By.XPATH, "//input[@id='password' and @name='password']").text
        b = driver.find_element(By.XPATH, "//input[@id='repassword' and @name='repassword']").text
        self.assertEqual(a, b)

        time.sleep(2)

        driver.find_element(By.XPATH, "//button[@id='login_btn']").click()
        time.sleep(2)


        driver.quit()

    def testLogin3(self):
        driver = webdriver.Chrome()

        driver.get("http://localhost:90/")

        driver.maximize_window()

        driver.find_element(By.XPATH, "/html/body/div/div/div/div[2]/a").click()

        time.sleep(2)
        username = "wangwu"
        password = "123456"
        repassword = "1234567"

        driver.find_element(By.XPATH,"//input[@id='username' and @name='username']").send_keys(username)
        time.sleep(2)
        driver.find_element(By.XPATH, "//input[@id='password' and @name='password']").send_keys(password)
        time.sleep(2)
        driver.find_element(By.XPATH, "//input[@id='repassword' and @name='repassword']").send_keys(repassword)
        time.sleep(2)
        a = driver.find_element(By.XPATH, "//input[@id='password' and @name='password']").text
        b = driver.find_element(By.XPATH, "//input[@id='repassword' and @name='repassword']").text
        self.assertEqual(a, b)

        time.sleep(2)

        driver.find_element(By.XPATH, "//button[@id='login_btn']").click()
        time.sleep(2)




        driver.quit()




